package com.dimples.dd.system.model.form;

import com.dimples.dd.common.annotation.IsMobile;
import com.dimples.dd.system.core.operatelog.DeptParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;

import java.util.List;
import java.util.Set;

/**
 * 用户表单对象
 *
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/6/20
 */
@Schema(description = "用户表单对象")
@Data
public class UserForm {

    @Schema(description = "用户编号", example = "1024")
    private Long id;

    @Schema(description = "用户账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudao")
    @NotBlank(message = "用户账号不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]{2,30}$", message = "用户账号由 数字、字母 组成")
    @Size(min = 4, max = 30, message = "用户账号长度为 2-30 个字符")
    @DiffLogField(name = "用户账号")
    private String username;

    @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
    @Size(max = 30, message = "用户昵称长度不能超过30个字符")
    @DiffLogField(name = "用户昵称")
    private String nickname;

    @Schema(description = "备注", example = "我是一个用户")
    @DiffLogField(name = "备注")
    private String remark;

    @Schema(description = "部门编号", example = "1")
    @DiffLogField(name = "部门", function = DeptParseFunction.NAME)
    private Long deptId;

    @Schema(description = "岗位编号数组", example = "1")
    @DiffLogField(name = "岗位")
    private Set<Long> postIds;

    @Schema(description = "用户邮箱", example = "dimples@163.com")
    @Email(message = "邮箱格式不正确")
    @Size(max = 50, message = "邮箱长度不能超过 50 个字符")
    @DiffLogField(name = "用户邮箱")
    private String email;

    @Schema(description = "手机号码", example = "18901691300")
    @IsMobile
    @DiffLogField(name = "手机号码")
    private String mobile;

    @Schema(description = "用户性别，参见 GenderEnum 枚举类", example = "1")
    @DiffLogField(name = "用户性别")
    private Integer gender;

    @Schema(description = "用户角色编码集合")
    @NotEmpty(message = "用户角色不能为空")
    private List<String> roles;

}
